package 牛客_面试必刷.Month07.day10;

public class 二叉搜索树的公共祖先 {
    public int lowestCommonAncestor (TreeNode root, int p, int q) {
        // write code here
        if(root.val > p && root.val > q){
            return lowestCommonAncestor(root.left,p,q);
        }
        if(root.val < p && root.val < q){
            return lowestCommonAncestor(root.right,p,q);
        }
        return root.val;
    }
}
